package com.zhixin.zhixinmall.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhixin.zhixinmall.entity.pojo.JdChannel;
import com.zhixin.zhixinmall.entity.vo.JdChannelVo;
import com.zhixin.zhixinmall.mapper.JdChannelMapper;
import com.zhixin.zhixinmall.service.JdChannelService;

/**
 * @author cyc
 * @date 2023/10/09 09:59:36
 */
@Service
public class JdChannelServiceImpl extends ServiceImpl<JdChannelMapper, JdChannel> implements JdChannelService {

    @Override
    public List<JdChannelVo> getIndexJdChannelList() {
        List<JdChannel> list = this.list();
        if (list.isEmpty()) {
            return null;
        }
        List<JdChannelVo> jdChannelVoList = new ArrayList<>();
        list.forEach(jdChannel -> {
            if (jdChannel.getChannelStatus() == 0) {
                JdChannelVo jdChannelVo = new JdChannelVo();
                BeanUtils.copyProperties(jdChannel, jdChannelVo);
                jdChannelVoList.add(jdChannelVo);
            }
        });
        return jdChannelVoList;
    }

    @Override
    public List<JdChannelVo> getCategoryJdChannelList() {
        List<JdChannel> list = this.list();
        if (list.isEmpty()) {
            return null;
        }
        List<JdChannelVo> jdChannelVoList = new ArrayList<>();
        list.forEach(jdChannel -> {
            if (jdChannel.getChannelStatus() == 1) {
                JdChannelVo jdChannelVo = new JdChannelVo();
                BeanUtils.copyProperties(jdChannel, jdChannelVo);
                jdChannelVoList.add(jdChannelVo);
            }
        });
        return jdChannelVoList;
    }
}
